from po.Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page(Base):
    # 断言账号登录
    dy1_loc=(By.CLASS_NAME,'loginbox-title')
    def dy1(self):
        return self.text(self.dy1_loc)
    # 进入框架
    kuangjia_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[1]/div/div[3]/div[1]/div[2]/iframe')
    # def kuangjia(self):
    #     self.frame(self.kuangjia_loc)
#     输入用户名
    name_loc=(By.NAME,'email')
    def name(self):
        self.send_keys(self.name_loc,'hj_3611292006')
#   输入密码
    password_loc=(By.NAME,'password')
    def password(self):
        self.send_keys(self.password_loc,'Hj3611292006')
    # 点击登录
    denglu_loc=(By.ID,'dologin')
    def denglu(self):
        self.click(self.denglu_loc)
    def test_login(self):
        try:
            self.goto('https://mail.163.com/')
            time.sleep(2)
            # assert '账号登录' in self.dy1()
            print(self.dy1())
            time.sleep(2)
            self.frame(self.kuangjia_loc)
            time.sleep(2)
            self.name()
            self.password()
            time.sleep(2)
            self.denglu()
            time.sleep(5)
            self.tframe()
            time.sleep(2)
        except Exception as e:
            times = time.strftime('%Y%m%d_%H%M%S', time.localtime())
            return self.driver.save_screenshot('hj' + times + '.png')

